package DoublePointer;

/**
 * @BelongsProject: SeniorArchitect-LeetCode
 * @BelongsPackage: DoublePointer
 * @Author: zhuangxiaoyan
 * @CreateTime: 2023-10-22  07:58
 * @Description: TODO
 * @Version: 1.0
 */
public class 判断子序列392 {

    // 采用双指针的方式来查找 判断元素是否已经查询最后了。如果没有，那就不是子序列了。
    public boolean isSubsequence(String s, String t) {
        int n = s.length(), m = t.length();
        int i = 0, j = 0;
        while (i < n && j < m) {
            if (s.charAt(i) == t.charAt(j)) {
                i++;
            }
            j++;
        }
        return i == n;
    }

}
